<script setup>
import { ref, reactive, shallowReactive, provide, computed, defineAsyncComponent } from 'vue'
// import Login from './views/Login.vue';
// import Home from './views/Home.vue';

const Login = defineAsyncComponent(()=> import('./views/Login.vue'));
const Home = defineAsyncComponent(()=> import('./views/Home.vue'));

//App中页面集合
const appPageData = {
    'Login': Login,
    'Home': Home
};

//处理页面刷新
let appCurrentViewName = localStorage.getItem('appCurrentView.name');
console.log('appCurrentViewName:', appCurrentViewName);
if (appCurrentViewName=='undefined' || appCurrentViewName=='null' || !appCurrentViewName) {
    appCurrentViewName = 'Login';
}
const appCurrentView = reactive({name: appCurrentViewName});
//检测页面切换
const appCurrentComp = computed(()=>{
    const comp = appPageData[appCurrentView.name];
    //存储当前页面
    localStorage.setItem('appCurrentView.name', appCurrentView.name);
    return comp;
});
//提供app页面切换操作
provide('appCurrentView', appCurrentView);

</script>
<template>
    <!-- <Login></Login> -->
    <component :is="appCurrentComp" />
</template>
<style scoped>
</style>
